<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		用户名：<input type="text" id="uname" name="uname" /><br/>
		密码：<input type="text" name="name" /><br />
		电话：<input type="text" name="name" /><br />
		地址：<input type="text" name="add" /><br />
		<input type="button" id="baocun" value="赋值" onclick="test2()" />
		<h1 id="h1">青鸟四班</h1>
		<button onclick="test3()">更改青鸟四班</button>
		
		<script type="text/javascript">
			//实现给用户名赋值
			function test(){
				document.getElementById("uname").value = "王";
			}
			
			//给所有的name=name的表单元素赋值为李
			function test1() {
				var n = document.getElementsByName("name");
				for(var i in n){
					n[i].value = "李";
				}
			}
			
			//给所有Input标签赋值为杨
			function test2(){
				var n = document.getElementsByTagName("input");
				for(var i in n){
					n[i].value = "杨";
				}
				document.getElementById("baocun").value="保存";
			}
			
			//动态更改值
			function test3(){
				var h1 = document.getElementById("h1");
				h1.innerHTML = "qn4class";
			}
			
			
			
			
		</script>
	</body>
</html>
